package com.study.pool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/** 
* @Description: 直接提交队列，拒绝策略是直接抛出异常
* @Param:
* @return:
* @Author: 朝花不迟暮 
* @Date: 2020/5/23 
*/
public class SynchronousQueue
{
    public static void main(String[] args)
    {
        ExecutorService pool = new ThreadPoolExecutor(1, 2, 1000,
                TimeUnit.MILLISECONDS, new java.util.concurrent.SynchronousQueue<>(),
                Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy());
        for (int i = 0; i < 3; i++)
        {
            pool.execute(new ThreadTask());
        }
        pool.shutdown();
    }
}
